Most materials used in optical devices and photonic devices change certain material properties with temperature, e.g., such as refractive index. Such changes with temperature tend to be undesirable because they can adversely affect the performance of such devices. For example, an optical resonator used in many applications may be intended to work at a specific resonance frequency. A shift in this resonance frequency of the optical resonator due to a temperature change would cause the resonance of the optical resonator to deviate from the specific resonance frequency at a certain temperature. To reduce such undesired thermal functions or dependence, a thermal control mechanism having a cooling element and/or heating element may be implemented in such a device to actively stabilize the performance of the device against temperature fluctuations.